package com.block.product.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.product.enums.UnionTypeEnum;
import com.block.product.service.IUnionLoginService;
import com.block.product.service.union.KeDaiUnionLoginService;
import com.block.product.service.union.*;

import java.util.HashMap;
import java.util.Map;

public class UnionLoginFactory {

    private static final Map<String, Class<? extends IUnionLoginService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(UnionTypeEnum.DEFAULT.getValue(), DefaultUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.YONGQIANFENQI.getValue(), YongQianFenqiUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.QIANXIAOHUA.getValue(), QianXiaoHuaUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.MENGXINHUA.getValue(), MengXinHuaUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.WEIJIEHUA.getValue(), WeiJieHuaUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.QUJIHUA.getValue(), QuJiHuaUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.HUARONG.getValue(), HuaRongUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.YINGDIAN.getValue(), YinDianUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.YUEDAIBAO.getValue(), YueDaiBaoUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.RONGYOUKE.getValue(), RongYouKeUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.KEDAI.getValue(), KeDaiUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.YICHEHANG.getValue(), YiCheHangUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.HAOHANYOUJIE.getValue(), HaoHanUnionLoginService.class);
        serviceMap.put(UnionTypeEnum.WEIXIAOFEIAPIS.getValue(), WeiXiaoFeiApisService.class);
        serviceMap.put(UnionTypeEnum.CHEDIRONG.getValue(), CheDiRongUnionLoginService.class);
    }

    public static IUnionLoginService getService(String accountType){
        if (serviceMap.containsKey(accountType)){
            Class<? extends IUnionLoginService> aClass = serviceMap.get(accountType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
